package com.hs.jpademo1.dao;

import com.hs.jpademo1.entity.Student;
import net.bytebuddy.agent.builder.AgentBuilder;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

/**
 * @ClassName StudentDao
 * @Description TODO
 */
@Repository
public interface StudentDao extends JpaRepository<Student,Integer> , JpaSpecificationExecutor<Student> {
    default int removeById(Integer id){
        Optional<Student> byId = findById(id);
        Student student = byId.get();
        student.setState(1);
        save(student);
        return 1;
    }

}
